/**   
* @Title: TaskExecutorConfig.java
* @Package com.springl.threads
* @Description: TODO(用一句话描述该文件做什么)
* @author antch,861710865@qq.com   
* @date 2017年7月13日 下午9:35:47
* @version V1.0   
*/


package com.springl.threads;

import java.util.concurrent.Executor;

import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.AsyncConfigurer;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

/**
* @ClassName: TaskExecutorConfig
* @Description: TODO(异步多线程spring配置)
* @author antch,861710865@qq.com
* @date 2017年7月13日 下午9:35:47
* 
*/
@EnableAsync//开启异步任务支持
@Configuration
@ComponentScan("com.springl.threads")
public class TaskExecutorConfig implements AsyncConfigurer {

	/*
	 * (非 Javadoc) 
	* <p>Title: getAsyncExecutor</p> 
	* <p>Description: 获取基于线程池TaskExecutor</p> 
	* @return 
	* @see org.springframework.scheduling.annotation.AsyncConfigurer#getAsyncExecutor()
	 */
	@Override
	public Executor getAsyncExecutor() {
		// TODO Auto-generated method stub
		ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
		taskExecutor.setCorePoolSize(5);
		taskExecutor.setMaxPoolSize(10);
		taskExecutor.setQueueCapacity(25);
		taskExecutor.initialize();
		return taskExecutor;
	}

	@Override
	public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
		// TODO Auto-generated method stub
		return null;
	}

}
